package com.rui.study.commons.study.support;

import com.rui.study.commons.study.entity.*;
import com.rui.study.commons.util.RandomUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;


public class CompanyHelper {

    private static final Logger LOGGER = LoggerFactory.getLogger(CompanyHelper.class);


    public static Company build() {

        Company company = new Company();

        /* 市场部 */
        List<Employee> marketSubordinates = new LinkedList<>();
        marketSubordinates.add(new Employee(RandomUtil.nextUserId(), "Timmy", 30, Gender.MALE) {
            @Override
            public void work() {
                LOGGER.info("营销");
            }
        });
        marketSubordinates.add(new Employee(RandomUtil.nextUserId(), "Sally", 20, Gender.FEMALE) {
            @Override
            public void work() {
                LOGGER.info("收款！");
            }
        });
        MarketDepartment marketDpt = new MarketDepartment(new Manager(RandomUtil.nextUserId(), "Mikel", 32, Gender.MALE, marketSubordinates));

        /* 开发部 */
        List<Employee> devSubordinates = new LinkedList<>();
        devSubordinates.add(new Employee(RandomUtil.nextUserId(), "Wilson", 27, Gender.MALE) {
            @Override
            public void work() {
                LOGGER.info("开发");
            }
        });
        devSubordinates.add(new Employee(RandomUtil.nextUserId(), "TaTa", 20, Gender.FEMALE) {
            @Override
            public void work() {
                LOGGER.info("测试");
            }
        });
        DevDepartment devDpt = new DevDepartment(new Manager(RandomUtil.nextUserId(), "john", 40, Gender.MALE, devSubordinates));
        company.setDepartment(new Department[]{marketDpt, devDpt});

        /* 股东 */
        Collection<String> stockholders = new LinkedList<>();
        stockholders.add("Tony");
        stockholders.add("Sonny");
        company.setStockholders(stockholders);

        return company;
    }

}
